<%@ page contentType="text/html;charset=GB2312"
	import="java.util.*, java.io.*, git.common.*
	, git.etl.Dao, java.sql.*
	, javax.naming.InitialContext, javax.naming.Context
	, javax.naming.NamingEnumeration" %>
<pre>
<%
	String catalog = request.getParameter("catalog");
	String schemaPattern = request.getParameter("schemaPattern");
	String tableNamePattern = request.getParameter("tableNamePattern");
	String types = request.getParameter("types");
	if ("null".equals(schemaPattern))
		schemaPattern = null;
	if ("null".equals(catalog))
		catalog = null;
	if (null == tableNamePattern)
		tableNamePattern = "%";
	
	String[] vtype = null;
	if ("null".equals(types))
		types = null;
	
	if (null != types)
		vtype = new String[] {types};
%>
</pre>
	<form>
		catalog: <input name="catalog" value="<%= catalog%>"><br>
		schemaPattern: <input name="schemaPattern" value="<%= schemaPattern%>"><br>
		tableNamePattern: <input name="tableNamePattern" value="<%= tableNamePattern%>"><br>
		types: <input name="types" value="<%= types%>"><br>
		<input type="submit"><br>
	</form>
	<table>
<%

	//Connection conn = DriverManager.getConnection("jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq=e:/fundinfo.MDB","dba","sql"); 
	//Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.16.2.8:1523:DEV","apps","aps10cu2"); 
	Connection conn = Dao.getConnectionByDataSourceName("java:comp/env/jdbc/COGDB");
	
	try
	{
		ResultSet rs = conn.getMetaData().getTables(catalog, schemaPattern, tableNamePattern, vtype);
		//ResultSet rs = conn.getMetaData().getColumns(catalog, schemaPattern, tableNamePattern, types);
		ResultSetMetaData rm = rs.getMetaData();
		
		{ %><tr><%
			for (int i = 0; i < rm.getColumnCount(); ++i)
			{
				%><td><%= rm.getColumnName(i + 1) %></td><%
			} %>
			</tr><%
		}
		while(rs.next())
		{ %><tr><%
			for (int i = 0; i < rm.getColumnCount(); ++i)
			{
				%><td><%= rs.getString(i + 1)%></td><%
			} %>
			</tr><%
		}
	}
	finally
	{
		conn.close();
	}
%>
</table>
